#业务类

from page.page_index import PageIndex
from page.page_login import PageLogin
from page.page_user import PageUser

class ServiceLogin(object):

    def __init__(self,driver,base_url):
        #初始化该业务有关的N个页面类对象
        self.page_index=PageIndex(driver,base_url)
        self.page_login=PageLogin(driver,base_url)
        self.page_user=PageUser(driver,base_url)


    def service_login_001(self,d):
        #完成首页
        self.page_index.openUrl()
        self.page_index.click_login()
        #完成登录页
        self.page_login.input_zanhao(d["zanhao"])
        self.page_login.input_pwd(d["pwd"])
        self.page_login.click_login()
        #完成个人中心页
        siji=self.page_user.getH2Text() #"laodon,欢迎光临"
        yuqi=d["yuqi"]
        return siji==yuqi

    def service_login_002(self,d):
        #完成首页
        self.page_index.openUrl()
        self.page_index.click_login()
        #完成登录页
        self.page_login.input_zanhao(d["zanhao"])
        self.page_login.input_pwd(d["pwd"])
        self.page_login.click_login()
        siji=self.page_login.getDivText() #"账号或密码错误"
        return siji==d["yuqi"]

    def service_login_003(self,d):
        #完成首页
        self.page_index.openUrl()
        self.page_index.click_login()
        #完成登录页
        self.page_login.input_zanhao(d["zanhao"])
        self.page_login.input_pwd(d["pwd"])
        self.page_login.click_login()
        siji=self.page_login.getPwdClassAttr() #"xxx invalid-text"
        return d["yuqi"] in siji

    def service_login_004(self,d):
        #完成首页
        self.page_index.openUrl()
        self.page_index.click_login()
        #完成登录页
        self.page_login.input_zanhao(d["zanhao"])
        self.page_login.input_pwd(d["pwd"])
        self.page_login.click_login()
        siji=self.page_login.getZanhaoClassAttr() #"xxx invalid-text"
        return d["yuqi"] in siji
